﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
using System.Windows;

namespace FA.FlightAttendant.View.Converters
{
    /// <summary>
    /// Converter used to hide a UI element when the collection that this
    /// converter is bound to is empty.
    /// </summary>
    [ValueConversion(typeof(int), typeof(Visibility))]
    public class HiddenIfEmptyConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int count = int.Parse(value.ToString());

            return (count <= 0) ? Visibility.Hidden : Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
